<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/12/16
  Time: 15:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>foreach</title>
</head>
<body>
    <%
        //往域对象存储一个集合
        List<String> list = new ArrayList<String>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add("赵六");
        list.add("田七");
        request.setAttribute("list", list);
    %>

    <table border="1" cellpadding="1" width="700" align="center">
        <tr>
            <th>下标</th>
            <th>计数</th>
            <th>姓名</th>
            <th>是否是第一个元素</th>
            <th>是否是最后一个元素</th>
        </tr>
        <c:forEach items="${list}" varStatus="vst">
            <tr>
                <td>${vst.index}</td>
                <td>${vst.count}</td>
                <td>${vst.current}</td>
                <td>${vst.first}</td>
                <td>${vst.last}</td>
            </tr>
        </c:forEach>
    </table>
</body>
</html>
